package com.imay.live.adapter;



import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import com.imay.live.view.custom.PricePayViewModel;
import com.imay.live.R;

import java.util.List;

/**
 * Created by liangzhenxiong on 2017/4/6 0006.
 * 充值
 */

public class RechargeLinearAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {


    public final static int VIEWTYPE_PRICE = 3;//价钱


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public RechargeLinearAdapter(List<MultiItemEntity> data) {
        super(data);
        addItemType(VIEWTYPE_PRICE, R.layout.item_price);
    }


    @Override
    protected void convert(final BaseViewHolder helper, MultiItemEntity item) {
        if (item.getItemType() == VIEWTYPE_PRICE) {
            if (item instanceof PricePayViewModel) {
                PricePayViewModel pricePayViewModel = (PricePayViewModel) item;
                helper.addOnClickListener(R.id.price_bg);
                helper.setText(R.id.tv_discount, pricePayViewModel.getAndroidDiamond() + helper.getConvertView().getResources().getString(R.string.recharge_word));
                helper.setText(R.id.tv_price, helper.getConvertView().getResources().getString(R.string.recharge_rmb) + pricePayViewModel.getAndroidMoney());

                if (pricePayViewModel.getAndroidFirstReward() > 0) {
                    helper.setVisible(R.id.price_zeng, true);
                    helper.setText(R.id.tv_vdiscount, "" + pricePayViewModel.getAndroidFirstReward());
                } else {
                    helper.setVisible(R.id.price_zeng, false);
                    helper.setText(R.id.tv_vdiscount, "");
                }

                if (pricePayViewModel.isChecked()) {
                    helper.setTextColor(R.id.tv_discount, helper.getConvertView().getResources().getColor(R.color.text_ff));
                    helper.setTextColor(R.id.tv_price, helper.getConvertView().getResources().getColor(R.color.text_7aff));
                    helper.setBackgroundRes(R.id.re_bg, R.drawable.shape_corner100_9e);
                } else {
                    helper.setTextColor(R.id.tv_discount, helper.getConvertView().getResources().getColor(R.color.text_21));
                    helper.setTextColor(R.id.tv_price, helper.getConvertView().getResources().getColor(R.color.text_70));
                    helper.setBackgroundRes(R.id.re_bg, R.drawable.shape_stroke100_e5);
                }

            }

        }

    }
}
